import request from "@/utils/request";
import md5 from 'js-md5';

class AuthAPI {
  /** 登录 接口*/
  static login(data) {
    // const formData = new FormData();
    // formData.append("username", data.username);
    // formData.append("password", data.password);
    // formData.append("captchaKey", data.captchaKey);
    // formData.append("captchaCode", data.captchaCode);
    return request({
      url: "/api/login",
      method: "post",
      data: {
        loginName: data.username,
        psw: md5(data.password),
      },
      headers: {
        // "Content-Type": "multipart/form-data",
      },
    });
  }

  /** 注销 接口*/
  static logout() {
    return request({
      url: "/api/v1/auth/logout",
      method: "delete",
    });
  }

  /** 获取验证码 接口*/
  static getCaptcha() {
    return request({
      url: "/api/v1/auth/captcha",
      method: "get",
    });
  }
}

export default AuthAPI;